import { getToken } from '@/utils';

// 保存用户登录成功后的token
// const initialState = localStorage.getItem('geek-pc-token') || '';
const initialState = getToken();

export const login = (state = initialState, action) => {
  // 存储用户登录的token
  if (action.type === 'login/token') {
    return action.payload;
  }

  // 清除token
  if (action.type === 'login/logout') {
    return '';
  }

  return state;
};
